<%@page import="com.jfinal.kit.PropKit" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" import="cn.com.dashihui.web.common.OrderCode" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>提现订单管理</title>
    <jsp:include page="../../include/header.jsp"></jsp:include>
    <style type="text/css">
			table th{
						text-align: center;
			 white-space: nowrap;
			        }
			table td{
						text-align: center;
			 white-space: nowrap;
			        }
			  table{
			         empty-cells:show; 
			         border-collapse: collapse;
			         margin:0 auto;
			        }
					 	  /*排序 */
			.querySort{
			   position:relative;
			}
			.down{
			   position: absolute;
			   top:12px;
			   display:inline-block;
			   width:10px;
			   height:12px;
			   margin-left: 8px;
			   background: url("${BASE_PATH}/static/images/sprite-arrow.png") 0 61px;
			}
		  .sort .querySort:NTH-OF-TYPE(2) .down{
			    top:-3px;
			    transform: rotateX(180deg);
			}
			.querySort:hover .down{
			   background: url("${BASE_PATH}/static/images/sprite-arrow.png") 0 21px;
			}
			
		  .downSort{
			    position: absolute;
			    top: 3px;
			    left: 3px;
			    width: 18px;
			    height: 24px;
			    opacity: 0;
			    cursor:pointer;
			}
		    .upSort {
			    position: absolute;
			    top: -15px;
			    left: 3px;
			    width: 18px;
			    height: 24px;
			    opacity: 0; 
			    cursor:pointer;
			}

 
		</style>
</head>
<body>
<div id="wrapper"  class="row">
	
			<div class="col-lg-12">
				<h1 class="page-header">提现订单统计</h1>
			</div>
		<!-- 搜索框 -->
			<div class="title-top col-lg-12">
		<div class="table-responsive panel panel-default" >
			<table id="dataTable" class="table table-hover table-bordered" style="overflow:scroll;">
	 			<thead>
	    			<tr>
						<th width="150px;">状态</th>
						<th width="200px;">提现号</th>
						<th width="80px;">会员姓名</th>
						<th width="150px;">会员卡号</th>
						<th width="200px;">银行卡</th>
						<th width="120px;">联系方式</th>
						<th width="200px;">下单时间</th>
						<th width="80px;">提现总价值</th>
						<th width="200px;">支付时间</th>
						<th width="100px;">经纪人</th>

					</tr>
				</thead>
				<tbody id="dataList"></tbody>
			</table>
		</div>
        	<div class="col-lg-12">
        		<div class = "pull-right">
        			<div class="text-muted  pull-left" style="margin-top:20px; margin-right:18px;">
					<select id="pageSize" name="pageSize" class="selectpicker" data-width="100" onchange="query()" >
    					<option value="10" selected = "selected">10条/页</option>
						<option value="15">15条/页</option>
						<option value="20">20条/页</option>
						<option value="50">50条/页</option>
						<option value="100">100条/页</option>
    				</select>
					</div>
        			<ul id="dataPagination" class="pagination-sm pull-right"></ul>
        		</div>
			</div>
		</div>
	</div>
<jsp:include page="../../include/javascripts.jsp"></jsp:include>
<!-- 异步加载下一页数据后，用模板渲染 -->
<script type="text/html" id="dataTpl">
		{{each list as item}}
				 <tr id="item{{item.orderNum}}" data-id="{{item.orderNum}}">
					{{if item.outStarte == 1}}
						<td>
							<a href="javascript:toMoneyAccept('{{item.orderNum}}');"><span class="btn">通过</span></a>
							<a href="javascript:toMoneyCancel('{{item.orderNum}}');"><span class="btn">驳回</span></a>
						</td>
					{{else if item.outStarte == 2}}
						<td>审核通过</td>
					{{else if item.outStarte == 3}}
						<td>审核驳回</td>
					{{else if item.outStarte == 4}}
						<td>转账完成</td>
					{{/if}}
					{{if item.tmState==1}}
						<td>
							<a href="javascript:doPass('{{item.tmId}}');"><span class="btn">通过</span></a>
							<a href="javascript:doReturn('{{item.tmId}}','{{item.tmJypoint}}');"><span class="btn">驳回</span></a>
						</td>
					{{else if item.tmState==2}}
						<td>
							<a href="javascript:return false;" style="opacity: 0.3"><span class="btn">通过</span></a>
							<a href="javascript:return false;" style="opacity: 0.3"><span class="btn">驳回</span></a>
						</td>
					{{else if item.tmState==3}}
						<td>
							<a href="javascript:return false;" style="opacity: 0.3"><span class="btn">通过</span></a>
							<a href="javascript:return false;" style="opacity: 0.3"><span class="btn">驳回</span></a>
						</td>
					{{/if}}
					<td>{{item.orderNum}}</td>
					<td>{{item.name}}</td>
					<td>{{item.card}}</td>
					<td>{{item.bankCardNo}}
						{{if !item.bankCardNo}}未绑定银行卡{{/if}}
					</td>
					<td>{{item.phone}}</td>
					<td>{{item.startDate}}</td>
					<td>{{item.amount}}</td>
					<td>{{item.payDate}}
						{{if !item.payDate}}尚未支付或已删除{{/if}}
					</td>
					<td>{{item.jjrName}}
						{{if !item.jjrName}}--{{/if}}
					</td>
				</tr>
		{{/each}}
</script>
<script type="text/javascript">
var dataPaginator;
var OrderNum="${OrderNum}";
var userId="${userId}";

$(query);
function query(){
	var pageSize=$("#pageSize").val();
	var  sSellerId = $("#sSellerId").val(),sStoreId = $("#sStoreId").val();
	var sell,store;
	if(sSellerId !=null && sSellerId !="" && sSellerId !=undefined){
		sell=sSellerId.join("','");
	}
	if(sStoreId !=null && sStoreId !="" && sStoreId !=undefined){
		store=sStoreId.join("','");
	}
	var params = {
		pageSize:pageSize,
		orderNum:$("#sOrderNum").val(),
		beginDate:$("#sBeginDate").val(),
		endDate:$("#sEndDate").val(),
		tel:$("#sTel").val(),
		state:$("#sState").val(),
		sellerId:sell,
		storeId:store,
		userId:userId
	};
	if(dataPaginator){
		dataPaginator.destroy();
	}
	dataPaginator = Kit.pagination("#dataPagination","${BASE_PATH}/ecard/order/extract",params,function(result){
		//设置显示最新的数据数量
		$("#dataCount").html(result.object.totalRow);
		//根据模板渲染数据并填充
		$("#dataList").empty().append(template("dataTpl",result.object));
		findTotal();
	});
}

/**
 * 此排序与默认排序冲突故分成二方法
 */
 function query1(index){
	   findTotal();
	   var pageSize=$("#pageSize").val();
		var  sSellerId = $("#sSellerId").val(),sStoreId = $("#sStoreId").val();
		var sell,store;
		if(sSellerId !=null && sSellerId !="" && sSellerId !=undefined){
			sell=sSellerId.join("','");
		}
		if(sStoreId !=null && sStoreId !="" && sStoreId !=undefined){
			store=sStoreId.join("','");
		}
		var params = {
			pageSize:pageSize,
			orderNum:$("#sOrderNum").val(),
			beginDate:$("#sBeginDate").val(),
			endDate:$("#sEndDate").val(),
			tel:$("#sTel").val(),
			state:$("#sState").val(),
			sellerId:sell,
			storeId:store,
			index:index
		};
		if(dataPaginator){
			dataPaginator.destroy();
		}
		dataPaginator = Kit.pagination("#dataPagination","${BASE_PATH}/ecard/order/page1",params,function(result){
			//设置显示最新的数据数量
			$("#dataCount").html(result.object.totalRow);
			//根据模板渲染数据并填充
			$("#dataList").empty().append(template("dataTpl",result.object));
			
		});
	}
function reset(){
	$("#sOrderNum").val("");$("#sBeginDate").val("");$("#sEndDate").val("");$("#sTel").val("");
	$("#sSellerId").val("");$("#sSellerId").trigger("change");  $("#sStoreId").val("");$("#sStoreId").trigger("change");  $("#sState").val("0");$("#sState").trigger("change");
	$("#sStoreId").selectpicker("refresh"); $("#sSellerId").selectpicker("refresh");
}
$("#sSellerId").change(function(){
	 var sSellerId=[];
	  sSellerId=$("#sSellerId").val();
	  $.ajax({
		type: "POST",
		url: "${BASE_PATH}/ecard/goods/chooseStore",
		data: {"sSellerId" : sSellerId},
		dataType: "json",
		traditional: true,
			success: function(data){
				 $("#sStoreId").empty();
				for(var i=0; i<data.object.length;i++){
					 $("#sStoreId").append("<option value='"+data.object[i].id+"'>"+data.object[i].title+"</option>");
				}
			$("#sStoreId").selectpicker("refresh");
			}
		});
	}); 
/**
 * 统计总所需积分和总现金价格
 */
function findTotal(){
	var sStoreId = $("#sStoreId").val();
	var sStoreId = $("#sStoreId").val();
	var store;
	if(sStoreId !=null && sStoreId !="" && sStoreId !=undefined){
		store=sStoreId.join("','");
	}
	var params = {
		pageSize:10,
		beginDate:$("#sBeginDate").val(),
		endDate:$("#sEndDate").val(),
		storeid:store,
		orderNum:$("#sOrderNum").val(),
		tel:$("#sTel").val(),
		state:$("#sState").val(),
		userId:userId
	};
	$.post("${BASE_PATH}/ecard/order/findTotal",params,function(result){
		if(result.flag==0){
			//$("#payPoint").text(result.object.payPoint);//总所需积分
			$("#amount").text(result.object.amount.toFixed(2));//总累计现金
			$("#tuikuan").text(result.object.tuikuan1.toFixed(2));//总退款现金
			$("#shiji").text(result.object.shiji.toFixed(2));//总实际现金
		}else{
			Kit.alert("操作失败");return;
		}
	});
}
</script>
</body>
</html>